A real-time graphics rendering system is used to create animation for graphics applications, such as video games. An animation is typically composed of a sequence of many frames. Each frame is an image that is created by the system from many primitives and control states.
Rendering of three-dimensional scenes typically requires realistic representation of multiple objects in the field of view. The distance of each object from the point of view (also known in 3D graphics as camera position) can determine whether the object blocks (occludes) or is blocked by other objects in the scene. Even in the case of a single object, some of its parts may block or be blocked by other parts depending upon each part's distance from the point of view. Methods and apparatus used to resolve occlusions and eliminate hidden surfaces play an important role in the creation of realistic images of three-dimensional scenes.
Many popular algorithms for hidden surface elimination utilize a special depth buffer, also known as a Z buffer. Each new pixel at a two-dimensional location X, Y on the screen is associated with a depth value Z. This value is compared with a depth value stored in the depth buffer at the location corresponding to the same X, Y coordinate. A visibility test compares the new and stored depth values; if the visibility test passes, meaning the new object is closer and therefore blocks the portion of the prior object at the same coordinates, then the depth value in the depth buffer is updated.
Here a pixel is defined as a set of parameters that represent an area of the object's surface corresponding to a point of the raster grid associated with the screen coordinate space. These parameters can include the two-dimensional coordinates of the point in the raster grid, as well as its color and depth values which correspond to the locations for the area as stored in a color buffer and in a depth buffer. A pixel is visible if its color and depth values are stored at the corresponding locations in the color buffer and in the depth buffer after scene rendering is completed. A pixel is invisible if its parameters are overwritten by another pixel having a depth value corresponding to the smaller distance from the camera.
The color of each pixel is generated by a primitive that is written to a color frame buffer, while the depth or Z value of the pixel is written to the depth buffer. If more than one primitive covers the same pixel, only the color of the pixel with the least depth is finally stored in the frame buffer. During the process of frame rendering, a depth engine ensures that the color of a pixel with the least depth value is written to the frame buffer by comparing the depth of a current pixel to the depth value stored in the depth buffer. After all primitives of a frame are rendered, the color buffer stores the final image of the frame.
At the beginning of a frame, the depth buffer has to be cleared to a value specified by the application so that the depth engine can process pixels correctly. Sometimes the color buffer must also be cleared to a specified color. These processes consume relatively large amounts of time and memory bandwidth. As a result, many researchers have proposed solutions to improve rendering efficiency, such as hierarchical Z buffer visibility, fast Z clear and lossless Z compression, and quasi-Z methods. While these methods do provide some improvement, they are still relatively slow and/or consume undesirably large amounts of memory bandwidth.
The present invention provides an improved system and method for clearing depth and color buffers in a real-time graphics rendering system, which substantially reduces the number of required clear actions and the associated memory consumption.